<template>
  <view class="two-step-auth">
    <!-- 返回按钮 -->
    <tn-button 
      backgroundColor="tn-bg-left" 
      style="color: black; position: absolute; left: 5%; top: 10%; width: 35px; height: 35px; font-size: 25px;" 
      :border="false" 
      @click="handleReturn"
    >
      <text class="tn-icon-left"></text>
    </tn-button>

    <!-- 页面标题 -->
    <view class="page-title">启用两步验证</view>

    <!-- 两步验证表单 -->
    <view class="form-container">
      <view class="info">
        为了增强账号安全性，我们建议您启用两步验证。请按照以下步骤操作：
      </view>
      <view class="step">
        1. 打开您的认证应用（如 Google Authenticator）并扫描以下二维码。
      </view>
      <view class="qr-code-container">
        <image src="/path/to/qr-code.png" class="qr-code"></image>
      </view>
      <view class="step">
        2. 输入认证应用生成的验证码。
      </view>
	  <tn-input
	    v-model="verificationCode" 
	    placeholder="请输入验证码" 
	    type="text" 
	    :clearable="true"
	  ></tn-input>
    </view>

    <!-- 保存按钮 -->
    <tn-button 
      backgroundColor="tn-bg-primary" 
      class="save-btn"
      @click="enableTwoStepAuth"
      :disabled="!verificationCode"
    >
      启用两步验证
    </tn-button>
  </view>
</template>

<script>
export default {
  data() {
    return {
      verificationCode: '',
    };
  },
  methods: {
    // 返回上一页
    handleReturn() {
      uni.navigateBack({ delta: 1 });
    },
    // 启用两步验证
    enableTwoStepAuth() {
      if (!this.verificationCode) {
        uni.showToast({
          title: '请输入验证码',
          icon: 'none'
        });
        return;
      }
      // 模拟启用两步验证
      uni.showToast({
        title: '两步验证启用成功',
        icon: 'success'
      });
      setTimeout(() => {
        uni.navigateBack({ delta: 1 });
      }, 1500);
    }
  }
};
</script>

<style scoped>
.two-step-auth {
  padding: 20px;
  background-color: #f5f5f5; /* 轻微灰色背景 */
  height: 100%;
}

.page-title {
  font-size: 28px;
  font-weight: bold;
  text-align: center;
  margin-top: 40px;
  color: #333;
  letter-spacing: 1px;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.form-container {
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-top: 40px;
}

.info, .step {
  font-size: 16px;
  color: #555;
  margin-bottom: 15px;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.qr-code-container {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.qr-code {
  width: 200px;
  height: 200px;
}

.input {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background-color: #fff;
  transition: border-color 0.3s ease;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.input:focus {
  border-color: #4d90fe;
  outline: none;
  box-shadow: 0 0 0 2px #4d90fe;
}

.save-btn {
  font-size: 18px;
  width: 100%;
  height: 45px;
  margin-top: 30px;
  border-radius: 5px;
  background: linear-gradient(135deg, #6d5dfc 0%, #788eff 100%);
  color: #fff;
  transition: background 0.3s ease;
  font-family: "宋体", SimSun, sans-serif; /* 修改字体为宋体 */
}

.save-btn:active {
  background: linear-gradient(135deg, #5a4ac6 0%, #667de0 100%);
}
</style>